﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using YLServiceCLient.YLAdminClient;
using YLServerInterface.ServerConfig;

namespace YLServerInterface
{
    /// <summary>
    /// Interaction logic for Login.xaml
    /// </summary>
    public partial class Login : Window
    {
        public Login()
        {
            InitializeComponent();
        }
        AdminServiceClient client;
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            client = AdminServiceClient.GetServiceClient();
            var guid = client.Login(txtName.Text, txtPwd.Text);
            if (guid != Guid.Empty)
            {
                MainWindow main = new MainWindow();
                main.Show();
                this.Hide();
                main.Closed += new EventHandler((o, arg) => this.Close());
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var config = YLServerConfig.GetConfig();
            txtName.Text = config.DefaultLoginName;
            txtPwd.Text = config.DefaultPwd;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Forms.EnvSetting setting = new Forms.EnvSetting();
            setting.ShowDialog();
        }

    }
}
